package com.jhm.internet1;
import java.net.*;
/*
* 发送数据包
* */
public class MyInternetDemo2 {
    public static void main(String[] args) throws Exception {
        DatagramSocket datagramSocket = new DatagramSocket();
        String str="你好吖~";
        byte[] bytes = str.getBytes();
        InetAddress address = InetAddress.getByName("127.0.0.1");
        int port=10086;

        DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length,address,port);
        datagramSocket.send(datagramPacket);
        datagramSocket.close();
    }
}
